package com.lecture.java8.reflection;

public class Demo01 {


    public static void main(String[] args) throws Exception {
        /*printClassInfo("".getClass());
        printClassInfo(Runnable.class);
        printClassInfo(java.time.Month.class);
        printClassInfo(String[].class);
        printClassInfo(int.class);*/

        Class<Student> stdCls = Student.class;
        Student student = new Student();
        student.score = 12;

        stdCls.getMethod("");
        System.out.println(stdCls.getField("score"));
        System.out.println(student.getClass().getDeclaredField("score").get(student));
    }

    public static void printClassInfo(Class cls) {
        System.out.println("Class name：" + cls.getName());
        System.out.println("Simple name：" + cls.getSimpleName());
        if (cls.getPackage() != null) {
            System.out.println("Package name：" + cls.getPackage().getName());
        }
        System.out.println("is interface：" + cls.isInterface());
        System.out.println("is enum：" + cls.isEnum());
        System.out.println("is array：" + cls.isArray());
        System.out.println("is primitive：" + cls.isPrimitive());
        System.out.println("----------------------------------------");
    }
}
